#include "stm32f10x.h"                  // Device header
#include "Delay.h"
#include "OLED.h"
#include "Serial.h"
#include <string.h>
#include "LED.h"

uint8_t arr1[] = {0x01, 0x02, 0x03, 0x04, 0x05};
uint8_t RxData = 0;
uint8_t i = 0;

//Hello Bird 程序
int main(void)
{
	LED_Init();
	OLED_Init();
	Serial_Init();
	OLED_ShowString(1, 1, "Hello Bird!");
	//OLED_ShowString(2, 1, "IX:");
	OLED_ShowString(3, 1, "RX:");
	//Serial_SendArray(arr1, 5);
	//Serial_SendString("Hello Wang Yi Ming!");
	//Serial_SendNum(12345, 5);
	//printf("Wang's Age = %d\n", 20);
	//Serial_Printf("王一鸣我爱你\r\n");

	
	while (1)
	{
		if (Serial_GetRxFlag() == 1)
		{
			OLED_ShowString(3, 4, "             ");
			OLED_ShowString(3, 4, Text_RXPack);
			Serial_SendTextPacket(Text_RXPack);
			if (strcmp(Text_RXPack, "LED_ON") == 0)
			{
				LED0_On();
				OLED_ShowString(2, 1, "LED_ON  OK");
			}
			else if (strcmp(Text_RXPack, "LED_OFF") == 0)
			{
				LED0_Off();
				OLED_ShowString(2, 1, "LED_OFF OK");
			}
			else    
			{
				OLED_ShowString(2, 1, "LED    ERR");	
			}
		}
	}
}
